$(document).ready(function(){

    var page=0

    findAll(page)
    $(".news-change span").click(function () {
        page=page+1;
        findAll(page)
    })
    function findAll(page){
        $.get("/artmanage/findall",{page:page},function (data) {
            console.log(data)
            if((data.news.totalPages-1)==page){
                $(".news-change").hide()
                $(".news-more").show()
            }
            var html=''
            for(i=0;i<data.news.content.length;i++) {
                html=html +'<li>\n' +
                    '\t\t\t\t\t\t<span data-toggle="modal" data-target="#myModal" class="news-list-card" onclick="findbyid('+data.news.content[i].id+')">\n' +
                    '\t\t\t\t\t\t\t<h3 class="h3">'+data.news.content[i].title+'</h3>\n' +
                    '\t\t\t\t\t\t\t<p class="p">'+data.news.content[i].text+'</p>\n' +
                    '\t\t\t\t\t\t\t<span class="more" >查看详情<i class="cui-icon cui-icon-more"></i></span>\n' +
                    '\t\t\t\t\t\t</span>\n' +
                    '\t\t\t\t\t</li>'
            }
            $(".news-list-v.show").html(html)
        })
    }


})
function findbyid(id) {
    console.log(id)
    $.get("/artmanage/findbyid",{id:id},function (data) {
       var time= timeChange(data.date)
        $(".modal-title").html(data.title)
        $("#time").html(time)
        $("#text").html(data.text)

    })
}
function timeChange(date1){
    var date=new Date(date1);
    var cy=date.getFullYear()+'-';
    var cm=date.getMonth()+1+'-';
    var cd=date.getDate();
    var cdate=cy+cm+cd;
    return cdate;
}